<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="./css/bootstrapStyle.css">
<script src='http://libs.baidu.com/jquery/1.10.2/jquery.min.js'></script>
<script type="text/javascript" src="./js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="./js/jquery.ztree.excheck.js"></script>
</head>
<body>
<ul id="treeDemo" class="ztree"></ul>

<script type="text/javascript">
		var setting = {
			check: {
				enable: true,
				nocheckInherit: true
			},
			data: {
				simpleData: {enable: true}
			}
		};
		var zNodes =[
			{ id:1, pId:0, name:"随意勾选 1", open:true},
			{ id:2, pId:0, name:"随意勾选 1", open:true},
			{ id:3, pId:0, name:"随意勾选 1", open:true},
			{ id:4, pId:0, name:"随意勾选 1", open:true},
			{ id:5, pId:0, name:"随意勾选 1", open:true},
		];

		function nocheckNode(e) {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			nocheck = e.data.nocheck,
			nodes = zTree.getSelectedNodes();
			if (nodes.length == 0) {
				alert("请先选择一个节点");
			}

			for (var i=0, l=nodes.length; i<l; i++) {
				nodes[i].nocheck = nocheck;
				zTree.updateNode(nodes[i]);
			}
		}

		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
			$("#nocheckTrue").bind("click", {nocheck: true}, nocheckNode);
			$("#nocheckFalse").bind("click", {nocheck: false}, nocheckNode);
		});


</script>
</body>
</html>